from knowtemarks.search.Filter import SearchFilter

def getResults(filters, kDao=None):
    filters = sorted(filters, key=lambda s: s._sortkey)
    results = set()
    if filters == []:
        filters.append(SearchFilter(kDao))
    i = 0
    while i < len(filters):
        if i == 0:
            for x in filters.pop().filterAll(): results.add(x)
        else:
            tmpRes = set()
            cf = filters.pop()
            print cf
            for x in cf.filter(results): tmpRes.add(x)
            results = tmpRes
        i += 1
    return results